#include <cstdlib>
#include <cstdio>
#include <ctime>

#include <QCoreApplication>

#include "base.h"
#include "session.h"

int main(int argc, char *argv[])
{
    // Use a fake core application, to check the arguments.
    QCoreApplication app(argc, argv);
    // Load the plugin from the provided arguments.
    if(app.arguments().size() != 2)
    {
        printf("Please specify the module dll to execute.\n");
        return -1;
     }
    // Create the session for the module.
    Session *session = Session::create_session(app.arguments().at(1), false, 6);
    if(!session)
    {
        printf("Session created failed: %s\n",
               Session::error_message().toLocal8Bit().data());
        return -1;
    }
    // Calculate the simulation time.
    clock_t time_req = clock();
    // Simulate for 10 steps.
    for(int i=0; i<10; ++i)
    {
        session->next_n_step(1000);
        printf("Simulated %d steps.\n", session->step());
    }
    printf("Time usage: %f\n", (clock() - time_req) * 1.0 / CLOCKS_PER_SEC * 1000);
    fflush(stdout);
    return 0;
}
